﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using WcfCloudMusic.DataContracts;
using WcfCloudMusic.DataLayer;

namespace WcfCloudMusic
{
    /// <summary>
    /// CloudMusic service
    /// </summary>
    [ServiceBehavior(AddressFilterMode = AddressFilterMode.Any)]
    public class CloudMusic : ICloudMusic
    {
        /// <summary>
        /// Logins the specified user. Authenticate user
        /// </summary>
        public int? Login(DCUser user)
        {
            if (user != null)
            {
                ICloudMusicDataLayer dataLayer = new CloudMusicDataLayer();
                return dataLayer.Login(user);
            }
            else
            {
                return null;
            }
        }


        /// <summary>
        /// Uploads the specified data. include gps,playlist , music , ....
        /// </summary>
        public bool Upload(DCUploadRequest data)
        {
            if (data.UserId == 0 || data.Gps == null || data.Music == null
                || data.Playlist == null || data.Trafic == null || data.Weather == null)
            {
                return false;
            }
            else
            { 
                ICloudMusicDataLayer dataLayer = new CloudMusicDataLayer();
                return dataLayer.Upload(data);
            }
        }


        public string Hello()
        {
            return "Hello";
        }
    }
}
